/**
 * Created by Yu Jin Xian on 2016/12/7.
 */
function circularReference() {
    function problem() {
        var objectA = new Object();
        var objectB = new Object();

        objectA.someOtherObject = objectB;
        objectB.anotherObject = objectA;
    }

    function comProblem() {
        var element = document.getElementById('some-element');
        var myObject = new Object();
        myObject.element = element;
        element.someObject = myObject;

        myObject.element = null;
        element.someObject = null;
    }
}

function manageMemory() {
    function createPerson(name) {
        var localPerson = new Object();
        localPerson.name = name;
        return localPerson;
    }

    var globalPerson = createPerson('Nicholas');
    globalPerson = null;            // 手工解除 globalPerson 的引用
}